<template>
  <div style="padding:20px">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item prop="keyword" label="关键字:">
        <el-input
          v-model="queryParams.keyword"
          placeholder="请输入关键字"
          clearable
          style="width: 240px"
        />
      </el-form-item>

      <el-form-item prop="status" label="报名状态:">
        <el-select v-model="queryParams.status" placeholder="请选择" style="width: 240px">
          <el-option label="已报名" value=0 />
          <el-option label="已取消" value=1 />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button
            type="primary"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
    </el-form>
    <el-table  :data="participantList" >
      <el-table-column
        label="序号"
        align="center"
        prop="id"
      />
      <el-table-column label="成员名称" align="center" prop="memberName" />
      <el-table-column label="性别" align="center" prop="memberSex">
        <template slot-scope="scope">
          <span v-if="scope.row.memberSex = 1">男</span>
          <span v-if="scope.row.memberSex = 0">女</span>
        </template>
      </el-table-column>
      <el-table-column label="联系方式" align="center" prop="phone" />
      <el-table-column
        label="任职情况"
        align="center"
        prop="employmentSituation"
      />
      <el-table-column label="工作单位" align="center" prop="workUnit" />
      <el-table-column label="地址" align="center" prop="communicationAddress" />
      <el-table-column label="报名时间" align="center" prop="createTime" />
      <el-table-column label="报名状态" align="center" prop="status" >
        <template slot-scope="scope">
          <span v-if="scope.row.status == 0">已报名</span>
          <span v-if="scope.row.status == 1">已取消</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script>
import { getMemberList } from '@/api/society'

export default {
  data(){
    return {
      //参会人员列表
      participantList:[],
      //活动id
      activityId:'',
      //总页数
      total:0,
      queryParams:{
        pageNum: 1,
        pageSize: 10,
        aid:'',
        status:'',
        keyword:'',
      },
      showSearch:true
    }
  },
  created(){
    this.getList()
  },
  methods:{
    //获取人员列表
    getList(){
      this.queryParams.aid=this.$route.query.key
      let params = {
        ...this.queryParams
      }
      getMemberList(params).then(res =>{
        if(res.code == 200){
          this.participantList = res.rows
          this.participantList.forEach((item,index)=>{
            this.$set(item,"id", index+1);
          })
          this.total = res.total
        }
      })
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageSize:10,
        pageNum:1,
        keyword:'',
        beginTime:'',
        endTime:'',
      },
      this.handleQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
  }
}
</script>
<style scoped>
.top1{
  height: 80px;
  display: flex;
  line-height: 60px;
  padding:10px 0px;
  background: #DDDDDD;
  font-size:14px;
  font-weight: 600;
}
.top1 > span{
  margin-left:40px
}
.top2{
  display: flex;
  background: #F8F8FB;font-size:14px;
  font-weight: 600;  line-height: 60px;
}
.top2 > span{
  margin-left:40px
}
</style>
